﻿using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace BGShell.Controls
{
    internal partial class HelpProgressControl : UserControl
    {
        public HelpProgressControl()
        {
            InitializeComponent();
        }

        [Browsable(true)]
        public override string Text
        {
            get { return lblStatus.Text; }
            set { lblStatus.Text = value; }
        }

        public event EventHandler Canceled
        {
            add { btnCancel.Click += value; }
            remove { btnCancel.Click -= value; }
        }

        [DefaultValue(null)]
        public double? Progress
        {
            get
            {
                if (progress.Style != ProgressBarStyle.Marquee)
                {
                    return progress.Value / 100.0;
                }

                return null;
            }

            set
            {
                if (value.HasValue)
                {
                    progress.Style = ProgressBarStyle.Continuous;
                    progress.Value = (int)(100 * value.Value);
                }
                else
                {
                    progress.Style = ProgressBarStyle.Marquee;
                }
            }
        }
    }
}
